#ifndef _INTERFACE_CONSOLE_MAIN_MENU_
#define _INTERFACE_CONSOLE_MAIN_MENU_

#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;

#include "console_settings.h"
#include "fraction_menu.h"
#include "expression_menu.h"
#include "expression_fraction_menu.h"
#include "equation_menu.h"
#include "linear_equation_menu.h"

namespace science
{
	namespace interface
	{
		namespace console
		{
			enum class MAIN_MENU_OPTIONS
			{
				OPTION_FRACTION,
				OPTION_EXPRESSION,
				OPTION_EXPRESSION_FRACTION,
				OPTION_EQUATION,
				OPTION_LINEAR_EQUATION,
				OPTION_EXIT,
				OPTION_UNKNOWN
			};

			class main_menu
			{
			public:
				static MAIN_MENU_OPTIONS show_menu()
				{
					console_settings::clear_screen();

					cout << "Choose option from the next menu:" << endl;
					cout << "  1 - Fraction processing." << endl;
					cout << "  2 - Expression processing." << endl;
					cout << "  3 - Expression farction processing." << endl;
					cout << "  4 - Equation processing." << endl;
					cout << "  5 - Linear Equation processing." << endl;
					cout << "  6 - Exit program." << endl << endl;

					int option = console_settings::get_int_option("Your option? ");

					switch (option)
					{
					case 1:
						return MAIN_MENU_OPTIONS::OPTION_FRACTION;
					case 2:
						return MAIN_MENU_OPTIONS::OPTION_EXPRESSION;
					case 3:
						return MAIN_MENU_OPTIONS::OPTION_EXPRESSION_FRACTION;
					case 4:
						return MAIN_MENU_OPTIONS::OPTION_EQUATION;
					case 5:
						return MAIN_MENU_OPTIONS::OPTION_LINEAR_EQUATION;
					case 6:
						return MAIN_MENU_OPTIONS::OPTION_EXIT;
					default:
						return MAIN_MENU_OPTIONS::OPTION_UNKNOWN;						
					}
				}

				static void run()
				{
					while (true)
					{
						MAIN_MENU_OPTIONS option = main_menu::show_menu();
						switch (option)
						{
						case science::interface::console::MAIN_MENU_OPTIONS::OPTION_FRACTION:
							fraction_menu::run();
							break;
						case science::interface::console::MAIN_MENU_OPTIONS::OPTION_EXPRESSION:
							expression_menu::run();
							break;
						case science::interface::console::MAIN_MENU_OPTIONS::OPTION_EXPRESSION_FRACTION:
							expression_fraction_menu::run();
							break;
						case science::interface::console::MAIN_MENU_OPTIONS::OPTION_EQUATION:
							equation_menu::run();
							break;
						case science::interface::console::MAIN_MENU_OPTIONS::OPTION_LINEAR_EQUATION:
							linear_equation_menu::run();
							break;
						case science::interface::console::MAIN_MENU_OPTIONS::OPTION_EXIT:
							return;
						case science::interface::console::MAIN_MENU_OPTIONS::OPTION_UNKNOWN:
							cout << endl << "Invalid option, please choose again.." << endl;
							break;
						default:
							break;
						}						
					};					
				}
			};
		}
	}
}

#endif